www.gusucode.com > 超声波测量以及形成图像 对相关信号进行模拟仿真 > 超声波测量以及形成图像 对相关信号进行模拟仿真/digital holograpy/dh/iscfilter_window.m
function varargout = iscfilter_window(varargin) % ISCFILTER_WINDOW M-file for iscfilter_window.fig % ISCFILTER_WINDOW, by itself, creates a new ISCFILTER_WINDOW or raises the existing % singleton*. % % H = ISCFILTER_WINDOW returns the handle to a new ISCFILTER_WINDOW or the handle to % the existing singleton*. % % ISCFILTER_WINDOW('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in ISCFILTER_WINDOW.M with the given input arguments. % % ISCFILTER_WINDOW('Property','Value',...) creates a new ISCFILTER_WINDOW or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before iscfilter_window_OpeningFunction gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to iscfilter_window_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help iscfilter_window % Last Modified by GUIDE v2.5 27-Aug-2007 16:18:39 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @iscfilter_window_OpeningFcn, ... 'gui_OutputFcn', @iscfilter_window_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin & isstr(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before iscfilter_window is made visible. function iscfilter_window_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to iscfilter_window (see VARARGIN) set(handles.lbox,'String',cell(1,0),'value',1); axes(handles.prev_axes) imagesc(ones(256)),colormap(gray); %axis equal tight; handles.mask=1; handles.it=1; handles.phase=[]; if nargin > 4 for n=1:2:length(varargin) if strcmpi(varargin{n},'phasemaps') handles.phase=varargin{n+1}; if ~isempty(handles.phase) set(handles.lbox,'string',sort(fieldnames(handles.phase))) end end end end % Choose default command line output for iscfilter_window handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes iscfilter_window wait for user response (see UIRESUME) uiwait(handles.iscfilter_window); % --- Outputs from this function are returned to the command line. function varargout = iscfilter_window_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure if isempty(findobj('type','figure','tag','iscfilter_window')) varargout{1}=[]; return end if strcmp(get(handles.done_button,'enable'),'off') varargout{1}=handles.phase; else varargout{1}=[]; end delete(handles.iscfilter_window) % --- Executes during object creation, after setting all properties. function lbox_CreateFcn(hObject, eventdata, handles) % hObject handle to lbox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: listbox controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end % --- Executes on selection change in lbox. function lbox_Callback(hObject, eventdata, handles) % hObject handle to lbox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns lbox contents as cell array % contents{get(hObject,'Value')} returns selected item from lbox if strcmp(get(handles.iscfilter_window,'SelectionType'),'open') prev_button_Callback(handles.prev_button, [], handles); end % --- Executes during object creation, after setting all properties. function mask_edit_CreateFcn(hObject, eventdata, handles) % hObject handle to mask_edit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function mask_edit_Callback(hObject, eventdata, handles) % hObject handle to mask_edit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of mask_edit as text % str2double(get(hObject,'String')) returns contents of mask_edit as a double handles.mask=str2num(get(hObject,'string')); if isempty(handles.mask) || ndims(handles.mask)>2 handles.mask=1; set(hObject,'string','1'); end guidata(hObject,handles) % --- Executes on button press in selected_radio. function selected_radio_Callback(hObject, eventdata, handles) % hObject handle to selected_radio (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of selected_radio if get(handles.all_radio,'value')==get(handles.all_radio,'max') set(hObject,'value',get(hObject,'max')) set(handles.all_radio,'value',get(handles.all_radio,'min')) else set(hObject,'value',get(hObject,'max')) end % --- Executes on button press in all_radio. function all_radio_Callback(hObject, eventdata, handles) % hObject handle to all_radio (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of all_radio if get(handles.selected_radio,'value')==get(handles.selected_radio,'max') set(hObject,'value',get(hObject,'max')) set(handles.selected_radio,'value',get(handles.selected_radio,'min')) else set(hObject,'value',get(hObject,'max')) end % --- Executes on button press in done_button. function done_button_Callback(hObject, eventdata, handles) % hObject handle to done_button (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) if isequal(get(handles.iscfilter_window, 'waitstatus'), 'waiting') % The GUI is still in UIWAIT, us UIRESUME set(hObject,'enable','off') uiresume(handles.iscfilter_window); else % The GUI is no longer waiting, just close it delete(handles.iscfilter_window); end % --- Executes when user attempts to close iscfilter_window. function iscfilter_window_CloseRequestFcn(hObject, eventdata, handles) % hObject handle to iscfilter_window (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: delete(hObject) closes the figure if isequal(get(handles.iscfilter_window, 'waitstatus'), 'waiting') % The GUI is still in UIWAIT, us UIRESUME uiresume(handles.iscfilter_window); else % The GUI is no longer waiting, just close it delete(handles.iscfilter_window); end % --- Executes on button press in prev_button. function prev_button_Callback(hObject, eventdata, handles) % hObject handle to prev_button (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) items=get(handles.lbox,'string'); index=get(handles.lbox,'value'); if isempty(items) || length(index)>1 return end axes(handles.prev_axes) [vx,vy]=opticimage(handles.phase(2).(items{index}).MN2,handles.phase(2).(items{index}).dxy2(1),... handles.phase(2).(items{index}).dxy2(2),handles.phase(2).(items{index}).center); imagesc(vx,vy,handles.phase(1).(items{index}),[-pi,pi]);colormap(gray);axis xy image; % --- Executes on button press in filter_button. function filter_button_Callback(hObject, eventdata, handles) % hObject handle to filter_button (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) items=get(handles.lbox,'string'); if isempty(items) || handles.it==0 || isequal(handles.mask,1) return end if get(handles.selected_radio,'value')==get(handles.selected_radio,'max') index=get(handles.lbox,'value'); items=items(index); end N=length(items); if N>1 h=waitbar(0,'Calculating...','Name','Please wait'); end for n=1:N handles.phase(1).(items{n})=SCfilter(handles.mask,handles.phase(1).(items{n}),handles.it); if N>1 waitbar(n/N,h); end end if N>1 close(h); end guidata(hObject,handles) prev_button_Callback(handles.prev_button, [], handles); % --- Executes during object creation, after setting all properties. function it_edit_CreateFcn(hObject, eventdata, handles) % hObject handle to it_edit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function it_edit_Callback(hObject, eventdata, handles) % hObject handle to it_edit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of it_edit as text % str2double(get(hObject,'String')) returns contents of it_edit as a double handles.it=round(abs(str2num(get(hObject,'string')))); if isempty(handles.it) || length(handles.it)>1 handles.it=1; end set(hObject,'string',num2str(handles.it)); guidata(hObject,handles)